1 /* 2 Java Regular Expressions Plugin API 3 4 Copyright (C) 2002 Jose San Leandro Armend?riz 5 jsanleandro@yahoo.es 6 chousz@yahoo.com 7 8 This library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU Lesser General Public 10 License as published by the Free Software Foundation; either 11 version 2.1 of the License, or (at your option) any later version. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 22 23 Thanks to ACM S.L. for distributing this library under the LGPL license. 24 Contact info: jsr000@terra.es 25 Postal Address: c/Playa de Lagoa, 1 26 Urb. Valdecaba?as 27 Boadilla del monte 28 28660 Madrid 29 Spain 30 31 This library uses an external API to retrieve version information at 32 runtime. 33 So far I haven't released such API as a project itself, but you should be 34 able to download it from the web page where you got this source code. 35 36 ****************************************************************************** 37 * 38 * Filename: $RCSfile: CompilerTest.java,v $ 39 * 40 * Author: Jose San Leandro Armend?riz 41 * 42 * Description: Performs some unit tests on RegexpManager class. 43 * 44 * Last modified by: $Author: chous $ at $Date: 2003/06/21 21:07:25 $ 45 * 46 * File version: $Revision: 1.1 $ 47 * 48 * Project version: $Name: $ 49 * ("Name" means no concrete version has been checked out) 50 * 51 * $Id: CompilerTest.java,v 1.1 2003/06/21 21:07:25 chous Exp $ 52 * 53 */ 54 package unittests.org.acmsl.regexpplugin; 55 56 /* 57 * Importing project-specific classes. 58 */ 59 import org.acmsl.regexpplugin.Compiler; 60 import org.acmsl.regexpplugin.Pattern; 61 import org.acmsl.regexpplugin.gnuregexp.CompilerGNUAdapter; 62 import org.acmsl.regexpplugin.gnuregexp.PatternGNUAdapter; 63 import org.acmsl.regexpplugin.jakartaoro.PatternOROAdapter; 64 import org.acmsl.regexpplugin.jakartaoro.Perl5CompilerOROAdapter; 65 import org.acmsl.regexpplugin.jakartaregexp.CompilerRegexpAdapter; 66 import org.acmsl.regexpplugin.jakartaregexp.PatternRegexpAdapter; 67 import org.acmsl.regexpplugin.jdk14regexp.CompilerJDKAdapter; 68 import org.acmsl.regexpplugin.jdk14regexp.PatternJDKAdapter; 69 import org.acmsl.regexpplugin.RegexpEngineNotFoundException; 70 import org.acmsl.regexpplugin.RegexpManager; 71 72 /* 73 * Importing some ACM classes. 74 */ 75 import org.acmsl.version.Version; 76 import org.acmsl.version.VersionFactory; 77 78 /*** 79 * Importing JUnit classes. 80 */ 81 import junit.framework.TestCase; 82 83 /*** 84 * Performs some unit tests on Compiler class. 85 * @testfamily JUnit 86 * @testkind testcase 87 * @testsetup Default TestCase 88 * @testedclass org.acm.regexpplugin.Compiler 89 * @see org.acmsl.regexpplugin.RegexpManager 90 * @author <a href="mailto:jsanleandro@yahoo.es" 91 >Jose San Leandro Armend?riz</a> 92 * @version $Revision: 1.1 $ 93 */ 94 public class CompilerTest 95 extends TestCase 96 implements org.acmsl.patterns.Test 97 { 98 /*** 99 * The test pattern. 100 */ 101 public static final String REGEXP = "A*b"; 102 103 /*** 104 * Constructs a test case with the given name. 105 * @param name the test case name. 106 */ 107 public CompilerTest(String name) 108 { 109 super(name); 110 } 111 112 /*** 113 * Tests the compiler.compile() method. 114 * @see org.acmsl.regexpplugin.Compiler 115 */ 116 public void testJakartaOroCompile() 117 { 118 try 119 { 120 RegexpManager.useJakartaOroPerl5(); 121 122 Compiler t_Compiler = RegexpManager.createCompiler(); 123 124 assertTrue(t_Compiler != null); 125 126 assertTrue(t_Compiler instanceof Perl5CompilerOROAdapter); 127 128 Pattern t_Pattern = t_Compiler.compile(REGEXP); 129 130 assertTrue(t_Pattern != null); 131 132 assertTrue(t_Pattern instanceof PatternOROAdapter); 133 } 134 catch (Exception exception) 135 { 136 fail("" + exception); 137 } 138 } 139 140 /*** 141 * Tests the compiler.compile() method. 142 * @see org.acmsl.regexpplugin.Compiler 143 */ 144 public void testJakartaRegexpCompile() 145 { 146 try 147 { 148 RegexpManager.useJakartaRegexp(); 149 150 Compiler t_Compiler = RegexpManager.createCompiler(); 151 152 assertTrue(t_Compiler != null); 153 154 assertTrue(t_Compiler instanceof CompilerRegexpAdapter); 155 156 Pattern t_Pattern = t_Compiler.compile(REGEXP); 157 158 assertTrue(t_Pattern != null); 159 160 assertTrue(t_Pattern instanceof PatternRegexpAdapter); 161 } 162 catch (Exception exception) 163 { 164 fail("" + exception); 165 } 166 } 167 168 /*** 169 * Tests the compiler.compile() method. 170 * @see org.acmsl.regexpplugin.Compiler 171 */ 172 public void testJDKCompile() 173 { 174 try 175 { 176 RegexpManager.useJDK14Regexp(); 177 178 Compiler t_Compiler = RegexpManager.createCompiler(); 179 180 assertTrue(t_Compiler != null); 181 182 assertTrue(t_Compiler instanceof CompilerJDKAdapter); 183 184 Pattern t_Pattern = t_Compiler.compile(REGEXP); 185 186 assertTrue(t_Pattern != null); 187 188 assertTrue(t_Pattern instanceof PatternJDKAdapter); 189 } 190 catch (Exception exception) 191 { 192 fail("" + exception); 193 } 194 } 195 196 /*** 197 * Tests the compiler.compile() method. 198 * @see org.acmsl.regexpplugin.Compiler 199 */ 200 public void testGNUCompile() 201 { 202 try 203 { 204 RegexpManager.useGNURegexp(); 205 206 Compiler t_Compiler = RegexpManager.createCompiler(); 207 208 assertTrue(t_Compiler != null); 209 210 assertTrue(t_Compiler instanceof CompilerGNUAdapter); 211 212 Pattern t_Pattern = t_Compiler.compile(REGEXP); 213 214 assertTrue(t_Pattern != null); 215 216 assertTrue(t_Pattern instanceof PatternGNUAdapter); 217 } 218 catch (Exception exception) 219 { 220 fail("" + exception); 221 } 222 } 223 224 /*** 225 * Concrete version object updated everytime it's checked-in in a CVS 226 * repository. 227 */ 228 public static final Version VERSION = 229 VersionFactory.createVersion("$Revision: 1.1 $"); 230 231 /*** 232 * Retrieves the current version of this object. 233 * @return the version object with such information. 234 */ 235 public Version getVersion() 236 { 237 return VERSION; 238 } 239 240 /*** 241 * Retrieves the current version of this class. It's defined because 242 * this is a utility class that cannot be instantiated. 243 * @return the object with class version information. 244 */ 245 public static Version getClassVersion() 246 { 247 return VERSION; 248 } 249 }

This page was automatically generated by Maven